package com.sujeet.learning.soap;

import java.util.Hashtable;

@SuppressWarnings("rawtypes")
public class CDCatalog {
	/** The CDs, by title */
	private Hashtable catalog;

	@SuppressWarnings("unchecked")
	public CDCatalog() {
		catalog = new Hashtable();

		// Seed the catalog
		addCD(new CD("Nickel Creek", "Nickel Creek", "Sugar Hill"));
		addCD(new CD("Let it Fall", "Sean Watkins", "Sugar Hill"));
		addCD(new CD("Aerial Boundaries", "Michael Hedges", "Windham Hill"));
		addCD(new CD("Taproot", "Michael Hedges", "Windham Hill"));

	}

	@SuppressWarnings("unchecked")
	public void addCD(CD cd) {
		if (cd == null) {
			throw new IllegalArgumentException("The CD object cannot be null.");
		}
		catalog.put(cd.getTitle(), cd);

	}

	public CD getCD(String title) {
		if (title == null) {
			throw new IllegalArgumentException("Title cannot be null.");
		}
		// Return the requested CD
		return (CD) catalog.get(title);
	}

//	public String getArtist(String title) {
//		if (title == null) {
//			throw new IllegalArgumentException("Title cannot be null.");
//		}
//
//		// Return the requested CD
//		return (String) catalog.get(title);
//	}

	public Hashtable list() {
		return catalog;
	}
}
